package com.itheima.controller.admin;

import com.itheima.constant.ShopConstant;
import com.itheima.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
@Slf4j
public class ShopController {



    @Autowired
    private RedisTemplate redisTemplate;

    @PutMapping("/{status}")
    @ApiOperation("店铺状态修改")
    public Result updateShopStatus(@PathVariable Long status){
            redisTemplate.opsForValue().set(ShopConstant.SHOP_STATUS_REDIS_KEY,status);
            return Result.success();
    }

    @GetMapping("/status")
    public Result getShopStatus(){
        Object o = redisTemplate.opsForValue().get(ShopConstant.SHOP_STATUS_REDIS_KEY);
        return Result.success(o);
    }

}

